package br.com.intelsys.entityutil.entity.dic;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import br.com.intelsys.basics.dao.hiber.DaoHiber;
import br.com.intelsys.entityutil.entity.dic.language.Language;
import br.com.intelsys.entityutil.entity.dic.language.LanguageHiber;

@Component
@Scope("request")
public class DicDao extends DaoHiber {

	@Autowired
	public DicDao(SessionFactory sessionFactory) {
		super(sessionFactory);
	}

	public Language getLanguage(int codLanguage) {
		Language l;
		if (codLanguage == 0) {
			l = null;
		} else {
			l = (Language) getQueryManager().get(LanguageHiber.class, codLanguage);
		}
		return l;
	}

	public List<Language> getLanguageList() {
		return getQueryManager().find("br.com.intelsys.entityutil.entity.dic.language.LanguageHiber.getLanguageList").getList();
	}

}